-
Notifications
You must be signed in to change notification settings - Fork 71
[LG-5587] fix(text-input): ref type missing #3167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
79287fd to
66ace9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a TypeScript issue where the TextInput component was not properly accepting ref props due to incorrect type definitions. The fix ensures that React refs work correctly with the TextInput component.
- Updated
BaseTextInputPropsto useReact.ComponentPropsWithRefinstead ofReact.ComponentPropsWithoutRef - Simplified the component type definition by removing the exported
TextInputComponentTypeand defining it inline - Added test coverage to verify that both
TextInputandTextAreacomponents properly accept refs
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/text-input/src/TextInput/TextInput.types.ts | Changed base props interface to support refs and removed exported component type |
| packages/text-input/src/TextInput/TextInput.tsx | Updated component typing to use inline type definition instead of exported type |
| packages/text-input/src/TextInput/TextInput.spec.tsx | Added test to verify TextInput accepts HTMLInputElement refs |
| packages/text-area/src/TextArea/TextArea.spec.tsx | Added test to verify TextArea accepts HTMLTextAreaElement refs |
|
Size Change: 0 B Total Size: 1.59 MB ℹ️ View Unchanged
|
|
Closing in favor of #3197 |
✍️ Proposed changes
The test showed how the
TextInputcould no longer take aref.I suggest fixing this by adopting a pattern already used in
TextArea(using `` to declareComponentPropsWithRef).As a drive-by I also aligned the
TextInputwithTextAreaby moving the component type declaration out of the.types.tsfile and declare theconstexport instead of using a type assertion, for a stronger guarantees.🎟 Jira ticket: LG-5587
✅ Checklist
For new components
For bug fixes, new features & breaking changes
pnpm changesetand documented my changes🧪 How to test changes